unit wbServerMethod;

interface

uses
  Windows, System.SysUtils, System.Classes,
  Data.SqlExpr, DBClient, Provider,
  Oracle, OracleData;

type

  TwbServerMethod = class(TSqlServerMethod)
  private
    FDatasetProvider: TDatasetProvider;
    FClientDataSet: TClientDataSet;
    function GetClientDataSet: TClientDataSet;
    //function GetClientDataSet: TClientDataSet;
    { Private declarations }
  protected
    { Protected declarations }
  public
    { Public declarations }
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
    //function ClientDataset: TClientDataSet;
    procedure Open;
    procedure Close;

    property ClientDataSet: TClientDataSet read GetClientDataSet;
  published
    { Published declarations }
  end;

implementation

{ TwbServerMethod }

{
function TwbServerMethod.ClientDataset: TClientDataSet;
begin
  Close;
  FClientDataSet.Close;
  Open;
  FClientDataSet.Open;
  Result := FClientDataSet;
end;
}

procedure TwbServerMethod.Open;
begin
  inherited;
  FClientDataSet.Open;
end;

procedure TwbServerMethod.Close;
begin
  FClientDataSet.Close;
  inherited;
end;

constructor TwbServerMethod.Create(AOwner: TComponent);
begin
  inherited;

  FClientDataSet := TClientDataSet.Create(Self);
  FClientDataSet.Name := Self.Name + 'Dataset';
  FClientDataSet.FetchOnDemand := True;
  // Include blobs with lengths <= MaxInt
  // IncludeBlobsInDelta(FClientDataSet, MaxInt);

  FDatasetProvider := TDatasetProvider.Create(Self);
  FDatasetProvider.Name := Self.Name + 'Provider';
  FDatasetProvider.Options := FDatasetProvider.Options + [poIncFieldProps];

  FClientDataSet.ProviderName := FDatasetProvider.Name;
  FDatasetProvider.DataSet := Self;
end;


destructor TwbServerMethod.Destroy;
begin
  FClientDataSet.Free;
  FDatasetProvider.Free;
  inherited;
end;


function TwbServerMethod.GetClientDataSet: TClientDataSet;
begin
  //FClientDataSet.Open;
  Result := FClientDataSet;
end;

end.
